#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @File  : mp4ToJpg.py
# @Time  : 2018/3/22  14:05
# @Author: 
# @Desc  : 


import cv2

cap = cv2.VideoCapture('aisha.mp4')
pic_num = 0
pic_name = 0

while (cap.isOpened()):
    pic_num += 1
    ret, img = cap.read()
    print(pic_num, ret)
    cv2.imshow('image', img)

    if pic_num % 3 == 0:
        pic_name += 1
        img_name = './img/' + str(pic_name) + '.jpg'
        cv2.imwrite(img_name, img)
        print(img_name + '\t保存成功！')

    k = cv2.waitKey(100)
    # q键退出
    if (k & 0xff == ord('q')):
        break

cap.release()
cv2.destroyAllWindows()
